<template>
  <div class="hello">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>员工资料</el-breadcrumb-item>
    </el-breadcrumb>

    <br />
    <el-row :span="24" class="titleclass">
      <el-col :span="4">
        <el-input
          v-model="inputParam"
          size="mini"
          prefix-icon="el-icon-search"
          placeholder="请输入员工姓名"
        ></el-input>
      </el-col>
      <el-col :span="1"><p></p></el-col>
      <el-col :span="2">
        <el-button
          type="primary"
          icon="el-icon-search"
          @click="getQueryEmployee()"
          size="mini"
          >搜索</el-button
        >
      </el-col>
      <el-col :span="2">
        <el-button
          type="primary"
          icon="el-icon-position"
          @click="showAdvSearchDialog()"
          size="mini"
          >高级搜索</el-button
        >
      </el-col>
      <el-col :span="7"><p></p></el-col>
      <el-col :span="2">
        <el-button
          type="success"
          icon="el-icon-upload2"
          @click="getQueryEmployee()"
          size="mini"
          >导入数据</el-button
        >
      </el-col>
      <el-col :span="1"><p></p></el-col>
      <el-col :span="2">
        <el-button
          type="success"
          icon="el-icon-download"
          @click="getQueryEmployee()"
          size="mini"
          >导出数据</el-button
        >
      </el-col>
      <el-col :span="1"><p></p></el-col>
      <el-col :span="2">
        <el-button
          type="primary"
          icon="el-icon-plus"
          @click="showAddEmployeeDialog()"
          size="mini"
          >增加员工</el-button
        >
      </el-col>
    </el-row>

    <el-dialog :visible.sync="advSearchDialog">
      <el-form :model="employeeAddForm" label-width="80px" :inline="true">
        <el-form-item label="政治面貌">
          <!-- select绑定变量=>下拉列表用户选择的值，默认只有一个 -->
          <el-select v-model="employeeAddForm.politicId" placeholder="请选择">
            <!-- option     循环数组显示多个 -->
            <el-option
              v-for="item in employeeAddFormPol"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="民族">
          <el-select v-model="employeeAddForm.nationId" placeholder="请选择">
            <el-option
              v-for="item in employeeAddFormNation"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="职位">
          <el-select v-model="employeeAddForm.posId" placeholder="请选择">
            <el-option
              v-for="item in employeeAddFormPos"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="职称">
          <el-select v-model="employeeAddForm.jobLevelId" placeholder="请选择">
            <el-option
              v-for="item in employeeAddFormJob"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="聘用形式">
          <el-input
            v-model="employeeAddForm.engageForm"
            prefix-icon="el-icon-edit"
            placeholder="请输入劳务合同或劳动合同"
          ></el-input>
        </el-form-item>

        <el-form-item label="所属部门">
          <el-select
            v-model="employeeAddForm.departmentId"
            placeholder="请选择"
          >
            <el-option
              v-for="item in employeeAddFormDept"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <!-- <el-form-item label="入职日期">
            <el-date-picker
            v-model="value01"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"  size="mini" value-format="yyyy-MM-dd">
            </el-date-picker>
      </el-form-item> -->

        <el-form-item>
          <el-button @click="advSearchDialog = false" size="mini"
            >取消</el-button
          >
          <el-button
            type="primary"
            icon="el-icon-search"
            @click="onSearch()"
            size="mini"
            >搜索</el-button
          >
        </el-form-item>
      </el-form>
    </el-dialog>

    <el-dialog title="增加员工" :visible.sync="addEmployeeDialog">
      <el-form :model="employeeAddForm" label-width="80px" :inline="true">
        <el-form-item label="姓名">
          <el-input
            v-model="employeeAddForm.name"
            prefix-icon="el-icon-edit"
            placeholder="请输入员工姓名"
          ></el-input>
        </el-form-item>
        <el-form-item label="性别">
          <el-input v-model="employeeAddForm.gender"></el-input>
        </el-form-item>

        <el-form-item label="出生日期">
          <el-date-picker
            v-model="birthday01"
            type="date"
            placeholder="出生日期"
            size="mini"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item label="政治面貌">
          <!-- select绑定变量=>下拉列表用户选择的值，默认只有一个 -->
          <el-select v-model="employeeAddForm.politicId" placeholder="请选择">
            <!-- option     循环数组显示多个 -->
            <el-option
              v-for="item in employeeAddFormPol"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="民族">
          <el-select v-model="employeeAddForm.nationId" placeholder="请选择">
            <el-option
              v-for="item in employeeAddFormNation"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="籍贯">
          <el-input
            v-model="employeeAddForm.nativePlace"
            prefix-icon="el-icon-edit"
            placeholder="请输入籍贯"
          ></el-input>
        </el-form-item>

        <el-form-item label="电子邮箱">
          <el-input
            v-model="employeeAddForm.email"
            prefix-icon="el-icon-edit"
            placeholder="请输入电子邮箱"
          ></el-input>
        </el-form-item>

        <el-form-item label="联系地址">
          <el-input
            v-model="employeeAddForm.address"
            prefix-icon="el-icon-edit"
            placeholder="请输入练习地址"
          ></el-input>
        </el-form-item>

        <el-form-item label="职位">
          <el-select v-model="employeeAddForm.posId" placeholder="请选择">
            <el-option
              v-for="item in employeeAddFormPos"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="职称">
          <el-select v-model="employeeAddForm.jobLevelId" placeholder="请选择">
            <el-option
              v-for="item in employeeAddFormJob"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="所属部门">
          <el-select
            v-model="employeeAddForm.departmentId"
            placeholder="请选择"
          >
            <el-option
              v-for="item in employeeAddFormDept"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="电话号码">
          <el-input
            v-model="employeeAddForm.phone"
            prefix-icon="el-icon-phone"
            placeholder="请输入电话号码"
          ></el-input>
        </el-form-item>

        <el-form-item
          label="工号"
          prefix-icon="el-icon-edit"
          placeholder="请输入员工工号"
        >
          <el-input v-model="employeeAddForm.workID"></el-input>
        </el-form-item>

        <el-form-item label="学历">
          <el-select
            v-model="employeeAddForm.tiptopDegree"
            placeholder="请选择"
          >
            <el-option
              v-for="item in employeeAddFormTip"
              :key="item.tiptopDegree"
              :label="item.tiptopDegree"
              :value="item.tiptopDegree"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="毕业院校">
          <el-input
            v-model="employeeAddForm.school"
            prefix-icon="el-icon-edit"
            placeholder="毕业院校名称"
          ></el-input>
        </el-form-item>

        <el-form-item label="专业名称">
          <el-input
            v-model="employeeAddForm.specialty"
            prefix-icon="el-icon-edit"
            placeholder="请输入专业名称"
          ></el-input>
        </el-form-item>

        <el-form-item label="入职日期">
          <el-date-picker
            v-model="begindate01"
            type="date"
            placeholder="入职日期"
            size="mini"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item label="转正日期">
          <el-date-picker
            v-model="conversionTime01"
            type="date"
            placeholder="转正日期"
            size="mini"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item label="合同起始日期">
          <el-date-picker
            v-model="beginContract01"
            type="date"
            placeholder="合同起始日期"
            size="mini"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item label="合同终止日期">
          <el-date-picker
            v-model="endContract01"
            type="date"
            placeholder="合同终止日期"
            size="mini"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item label="身份证号">
          <el-input
            v-model="employeeAddForm.idCard"
            prefix-icon="el-icon-edit"
            placeholder="请输入身份证号码"
          ></el-input>
        </el-form-item>

        <el-form-item label="聘用形式">
          <el-input v-model="employeeAddForm.engageForm"></el-input>
        </el-form-item>

        <el-form-item label="婚姻状况">
          <el-input v-model="employeeAddForm.wedlock"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button @click="addEmployeeDialog = false">取消</el-button>
          <el-button type="primary" @click="onSubmit()">立即创建</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <template>
      <el-table :data="Employee" border style="width: 100%">
        <el-table-column type="selection"></el-table-column>
        <el-table-column
          fixed
          prop="name"
          label="姓名"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="workID"
          label="工号"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="gender"
          label="性别"
          width="70"
        ></el-table-column>
        <el-table-column
          prop="birthday"
          label="出生日期"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="idCard"
          label="身份证号"
          width="170"
        ></el-table-column>

        <el-table-column
          prop="wedlock"
          label="婚姻状况"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="nation.name"
          label="民族"
          width="80"
        ></el-table-column>
        <el-table-column
          prop="nativePlace"
          label="籍贯"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="politicsstatus.name"
          label="政治面貌"
          width="120"
        ></el-table-column>

        <el-table-column
          prop="email"
          label="电子邮件"
          width="160"
        ></el-table-column>
        <el-table-column
          prop="phone"
          label="电话号码"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="address"
          label="联系地址"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="department.name"
          label="所属部门"
          width="120"
        ></el-table-column>

        <el-table-column
          prop="position.name"
          label="职位"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="jobLevel.name"
          label="职称"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="engageForm"
          label="聘用形式"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="tiptopDegree"
          label="最高学历"
          width="120"
        ></el-table-column>

        <el-table-column
          prop="specialty"
          label="专业"
          width="160"
        ></el-table-column>
        <el-table-column
          prop="school"
          label="毕业院校"
          width="130"
        ></el-table-column>
        <el-table-column
          prop="beginDate"
          label="入职日期"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="conversionTime"
          label="转正日期"
          width="120"
        ></el-table-column>

        <el-table-column
          prop="beginContract"
          label="合同起始日期"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="endContract"
          label="合同截止日期"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="contractTerm"
          label="合同期限"
          width="120"
        ></el-table-column>

        <el-table-column
          label="操作"
          show-overflow-tooltip
          fixed="right"
          width="160"
        >
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
              >编辑</el-button
            >
            <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </template>
    <template>
      <div class="block">
        <el-pagination
          background
          @current-change="pageChange"
          layout="prev, pager, next"
          :current-page.sync="pageNum"
          :total="allCountNum"
        >
        </el-pagination>
      </div>
      <el-dialog title="修改员工信息" :visible.sync="updateEmployeeDialog">
        <el-form :model="employeeUpdateForm" label-width="100px" :inline="true">
          <el-form-item label="姓名">
            <el-input v-model="employeeUpdateForm.name"></el-input>
          </el-form-item>
          <el-form-item label="性别">
            <el-input v-model="employeeUpdateForm.gender"></el-input>
          </el-form-item>

          <el-form-item label="出生日期">
            <el-date-picker
              v-model="birthday02"
              type="date"
              placeholder="出生日期"
              size="mini"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-form-item>

          <el-form-item label="政治面貌">
            <!-- select绑定变量=>下拉列表用户选择的值，默认只有一个 -->
            <el-select
              v-model="employeeUpdateForm.politicId"
              placeholder="请选择"
            >
              <!-- option     循环数组显示多个 -->
              <el-option
                v-for="item in employeeAddFormPol"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="民族">
            <el-select
              v-model="employeeUpdateForm.nationId"
              placeholder="请选择"
            >
              <el-option
                v-for="item in employeeAddFormNation"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="籍贯">
            <el-input v-model="employeeUpdateForm.nativePlace"></el-input>
          </el-form-item>

          <el-form-item label="电子邮箱">
            <el-input v-model="employeeUpdateForm.email"></el-input>
          </el-form-item>

          <el-form-item label="联系地址">
            <el-input v-model="employeeUpdateForm.address"></el-input>
          </el-form-item>

          <el-form-item label="职位">
            <el-select v-model="employeeUpdateForm.posId" placeholder="请选择">
              <el-option
                v-for="item in employeeAddFormPos"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="职称">
            <el-select
              v-model="employeeUpdateForm.jobLevelId"
              placeholder="请选择"
            >
              <el-option
                v-for="item in employeeAddFormJob"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="所属部门">
            <el-select
              v-model="employeeUpdateForm.departmentId"
              placeholder="请选择"
            >
              <el-option
                v-for="item in employeeAddFormDept"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="电话号码">
            <el-input v-model="employeeUpdateForm.phone"></el-input>
          </el-form-item>

          <el-form-item label="工号">
            <el-input v-model="employeeUpdateForm.workID"></el-input>
          </el-form-item>

          <el-form-item label="学历">
            <el-select
              v-model="employeeUpdateForm.tiptopDegree"
              placeholder="请选择"
            >
              <el-option
                v-for="item in employeeAddForm"
                :key="item.id"
                :label="item.tiptopDegree"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="毕业院校">
            <el-input v-model="employeeUpdateForm.school"></el-input>
          </el-form-item>

          <el-form-item label="专业名称">
            <el-input v-model="employeeUpdateForm.specialty"></el-input>
          </el-form-item>

          <el-form-item label="入职日期">
            <el-date-picker
              v-model="begindate02"
              type="date"
              placeholder="入职日期"
              size="mini"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-form-item>

          <el-form-item label="转正日期">
            <el-date-picker
              v-model="conversionTime02"
              type="date"
              placeholder="转正日期"
              size="mini"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-form-item>

          <el-form-item label="合同起始日期">
            <el-date-picker
              v-model="beginContract02"
              type="date"
              placeholder="合同起始日期"
              size="mini"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-form-item>

          <el-form-item label="合同终止日期">
            <el-date-picker
              v-model="endContract02"
              type="date"
              placeholder="合同终止日期"
              size="mini"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-form-item>

          <el-form-item label="身份证号">
            <el-input v-model="employeeUpdateForm.idCard"></el-input>
          </el-form-item>

          <el-form-item label="聘用形式">
            <el-input v-model="employeeUpdateForm.engageForm"></el-input>
          </el-form-item>

          <el-form-item label="婚姻状况">
            <el-input v-model="employeeUpdateForm.wedlock"></el-input>
          </el-form-item>
          <br />
          <el-form-item>
            <el-button @click="updateEmployeeDialog = false">取消</el-button>
            <el-button type="primary" @click="updateSubmit()"
              >立即修改</el-button
            >
          </el-form-item>
        </el-form>
      </el-dialog>
    </template>
  </div>
</template>

<script>
export default {
  name: "EmpBasic",
  data() {
    return {
      inputParam: "",
      allCountNum: 0,
      pageNum: 1,
      pageSize: 8,
      Employee: [{}],
      addEmployeeDialog: false,
      advSearchDialog: false,
      updateEmployeeDialog: false,
      value01: "",
      birthday01: "",
      birthday02: "",
      begindate01: "",
      begindate02: "",
      conversionTime01: "",
      conversionTime02: "",
      beginContract01: "",
      beginContract02: "",
      endContract01: "",
      endContract02: "",
      employeeAddForm: {
        name: "",
        gender: "",
        birthday: "",
        politicId: "",
        nationId: "",
        nativePlace: "",
        email: "",
        address: "",
        posId: "",
        jobLevelId: "",
        departmentId: "",
        phone: "",
        workID: "",
        tiptopDegree: "",
        school: "",
        specialty: "",
        beginDate: "",
        conversionTime: "",
        beginContract: "",
        endContract: "",
        idCard: "",
        engageForm: "",
        wedlock: "",
      },
      employeeAddFormTip: [],
      employeeAddFormJob: [],
      employeeAddFormNation: [],
      employeeAddFormPol: [],
      employeeAddFormPos: [],
      employeeAddFormDept: [],
      employeeUpdateForm: {
        name: "",
        gender: "",
        birthday: "",
        politicId: "",
        nationId: "",
        nativePlace: "",
        email: "",
        address: "",
        posId: "",
        jobLevelId: "",
        departmentId: "",
        phone: "",
        workID: "",
        tiptopDegree: "",
        school: "",
        specialty: "",
        beginDate: "",
        conversionTime: "",
        beginContract: "",
        endContract: "",
        idCard: "",
        engageForm: "",
        wedlock: "",
        id: "",
      },
    };
  },
  created() {
    //页面加载之后，自动执行下面语句
    this.getAllEmployee();
    this.getType();
  },
  methods: {
    getQueryEmployee() {
      if (this.inputParam == "") {
        this.getAllEmployee();
      }

      this.$axios
        .post(
          "EmployeeController/listLikeEmployee",
          this.$qs.stringify({
            name: this.inputParam,
          })
        )
        .then((res) => {
          this.Employee = res.data;
        })
        .catch((value) => {
          console.error(value);
        });
      this.pageNum = 1;
    },
    onSearch() {
      console.log(this.value01[0]);
      this.$axios
        .post(
          "EmployeeController/advSearchEmployee",
          this.$qs.stringify({
            politicId: this.employeeAddForm.politicId,
            nationId: this.employeeAddForm.nationId,
            posId: this.employeeAddForm.posId,
            jobLevelId: this.employeeAddForm.jobLevelId,
            engageForm: this.employeeAddForm.engageForm,
            departmentId: this.employeeAddForm.departmentId,
            /* beginDate:this.value01, */
          })
        )
        .then((res) => {
          this.advSearchDialog = false;
          this.Employee = res.data;
        })
        .catch((value) => {
          console.error(value);
        });
    },
    onSubmit() {
      //h5游览器支持，全局变量，保存在localStorage中的数据，不会随游览器的关闭消失
      // localStorage.setItem();

      this.$axios
        .post(
          "EmployeeController/saveEmployee",
          this.$qs.stringify({
            name: this.employeeAddForm.name,
            gender: this.employeeAddForm.gender,
            birthday: this.birthday01,
            politicId: this.employeeAddForm.politicId,
            nationId: this.employeeAddForm.nationId,
            nativePlace: this.employeeAddForm.nativePlace,
            email: this.employeeAddForm.email,
            address: this.employeeAddForm.address,
            posId: this.employeeAddForm.posId,
            jobLevelId: this.employeeAddForm.jobLevelId,
            departmentId: this.employeeAddForm.departmentId,
            phone: this.employeeAddForm.phone,
            workID: this.employeeAddForm.workID,
            tiptopDegree: this.employeeAddForm.tiptopDegree,
            school: this.employeeAddForm.school,
            specialty: this.employeeAddForm.specialty,
            beginDate: this.begindate01,
            conversionTime: this.conversionTime01,
            beginContract: this.beginContract01,
            endContract: this.endContract01,
            idCard: this.employeeAddForm.idCard,
            engageForm: this.employeeAddForm.engageForm,
            wedlock: this.employeeAddForm.wedlock,
          })
        )
        .then((res) => {
          this.addEmployeeDialog = false;
          this.Employee = res.data;
          this.getAllEmployee();
          this.pageNum = 1;
        });
    },

    //提交编辑
    updateSubmit() {
      this.$axios
        .post(
          "EmployeeController/updateEmployee",
          this.$qs.stringify({
            name: this.employeeUpdateForm.name,
            gender: this.employeeUpdateForm.gender,
            birthday: this.birthday02,
            politicId: this.employeeUpdateForm.politicId,
            nationId: this.employeeUpdateForm.nationId,
            nativePlace: this.employeeUpdateForm.nativePlace,
            email: this.employeeUpdateForm.email,
            address: this.employeeUpdateForm.address,
            posId: this.employeeUpdateForm.posId,
            jobLevelId: this.employeeUpdateForm.jobLevelId,
            departmentId: this.employeeUpdateForm.departmentId,
            phone: this.employeeUpdateForm.phone,
            tiptopDegree: this.employeeUpdateForm.tiptopDegree,
            school: this.employeeUpdateForm.school,
            specialty: this.employeeUpdateForm.specialty,
            beginDate: this.begindate02,
            conversionTime: this.conversionTime02,
            beginContract: this.beginContract02,
            endContract: this.endContract02,
            idCard: this.employeeUpdateForm.idCard,
            engageForm: this.employeeUpdateForm.engageForm,
            wedlock: this.employeeUpdateForm.wedlock,
            id: this.employeeUpdateForm.id,
          })
        )
        .then((res) => {
          this.$message("已经修改:" + this.employeeUpdateForm.name);
          this.updateEmployeeDialog = false;
          this.Employee = res.data;
          this.getAllEmployee(this.pageNum);
        });
    },
    getAllEmployee(pageNum) {
      pageNum ? (this.pageNum = pageNum) : "";
      this.$axios
        .post(
          "EmployeeController/listEmployee",
          this.$qs.stringify({
            pageNum: this.pageNum,
            pageSize: this.pageSize,
          })
        )
        .then((res) => {
          this.Employee = res.data.list;
          this.allCountNum = res.data.total;
        })
        .catch((value) => {
          console.error(value);
        });
    },
    showAddEmployeeDialog() {
      this.addEmployeeDialog = true;
    },
    showAdvSearchDialog() {
      this.advSearchDialog = true;
    },
    getType() {
      //发挥axios请求后，前端代码就会继续执行下一行
      this.$axios
        .post("EmployeeController/getEmployeeTiptopDegree")
        .then((res) => {
          this.employeeAddFormTip = res.data;
        })
        .catch((value) => {
          console.error(value);
        });

      this.$axios
        .post("PoliticsstatusController/listPoliticsstatus")
        .then((res) => {
          this.employeeAddFormPol = res.data;
        })
        .catch((value) => {
          console.error(value);
        });

      this.$axios
        .post("NationController/listNation")
        .then((res) => {
          this.employeeAddFormNation = res.data;
        })
        .catch((value) => {
          console.error(value);
        });

      this.$axios
        .post("basic/PositionController/getAllPosition")
        .then((res) => {
          this.employeeAddFormPos = res.data;
        })
        .catch((value) => {
          console.error(value);
        });

      this.$axios
        .post("basic/JobLevelController/getAllJobLevel")
        .then((res) => {
          this.employeeAddFormJob = res.data;
        })
        .catch((value) => {
          console.error(value);
        });

      this.$axios
        .post("basic/DepartmentController/listDepartment")
        .then((res) => {
          this.employeeAddFormDept = res.data;
        })
        .catch((value) => {
          console.error(value);
        });
    },
    //编辑员工信息
    handleEdit(index, row) {
      this.updateEmployeeDialog = true;

      (this.employeeUpdateForm.name = row.name),
        (this.employeeUpdateForm.gender = row.gender),
        (this.birthday02 = row.birthday),
        (this.employeeUpdateForm.politicId = row.politicId),
        (this.employeeUpdateForm.nationId = row.nationId),
        (this.employeeUpdateForm.nativePlace = row.nativePlace),
        (this.employeeUpdateForm.email = row.email),
        (this.employeeUpdateForm.address = row.address),
        (this.employeeUpdateForm.posId = row.posId),
        (this.employeeUpdateForm.jobLevelId = row.jobLevelId),
        (this.employeeUpdateForm.departmentId = row.departmentId),
        (this.employeeUpdateForm.phone = row.phone),
        (this.employeeUpdateForm.workID = row.workID),
        (this.employeeUpdateForm.tiptopDegree = row.tiptopDegree),
        (this.employeeUpdateForm.school = row.school),
        (this.employeeUpdateForm.specialty = row.specialty),
        (this.begindate02 = row.beginDate),
        (this.conversionTime02 = row.conversionTime),
        (this.beginContract02 = row.beginContract),
        (this.endContract02 = row.endContract),
        (this.employeeUpdateForm.idCard = row.idCard),
        (this.employeeUpdateForm.engageForm = row.engageForm),
        (this.employeeUpdateForm.wedlock = row.wedlock),
        //通过给id赋值，确定要修改的行
        (this.employeeUpdateForm.id = row.id);

      /*       //确定下拉框的默认值
      this.deptUpdateForm.deptclassify = row.cid;
      this.deptUpdateForm.depttype = row.tid; */
    },
    handleDelete(index, row) {
      //根据下标取当前行的编号
      this.$confirm("确定删除:" + row.name + "吗").then(() => {
        this.$message("已经删除:" + row.name);
        this.$axios
          .post(
            "EmployeeController/removeEmployeeById",
            this.$qs.stringify({ id: row.id })
          )
          .then((res) => {
            this.Employee = res.data;
            this.getAllEmployee(this.pageNum);
          });
      });
    },
    //分页：得到显示的总行数，根据页数得到显示的行数
    //总行数：select count(*) from deptment
    //显示的行数：select * from deptment limit (pageNum-1)*10,10
    //List<Map>  map.put()
    pageChange(pageNum) {
      this.$message(pageNum + "");
      this.pageNum = pageNum;
      this.getAllEmployee(pageNum);
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
a {
  color: #42b983;
}
.titleclass {
  text-align: left;
}
</style>
